package com.aier.admin_new.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.aier.admin_new.entity.RoleMenus;
import com.aier.admin_new.entity.mapper.RoleMenusRowMapper;
import com.aier.admin_new.service.IRoleMenusService;
import com.aier.common.dao.ICommonDAO;
@Service("roleMenusService")
public class RoleMenusServiceImpl implements IRoleMenusService {
	
    @Resource(name = "commonDao")
    private ICommonDAO commonDao;
    
    
    @SuppressWarnings("unchecked")
	@Override
	public List<RoleMenus> searchRoleMenusParentId() {
		List<RoleMenus> list=(List<RoleMenus>)commonDao.list("SELECT * FROM rolemenus      WHERE  roletype = 0  AND parentid=0" ,
				new RoleMenusRowMapper());
		return list;
	}

    @SuppressWarnings("unchecked")
	@Override
	public List<RoleMenus> searchRoleMenusChildId(int roletype,int parentid) {
		List<RoleMenus> list=(List<RoleMenus>)commonDao.list("SELECT * FROM  rolemenus     WHERE  roletype =? and parentid=?",
				new Object[]{ roletype,parentid},
				new RoleMenusRowMapper());
		return list;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<RoleMenus> searchRoleMenusByRoletype(String roletype) {
		String sql ="SELECT  * FROM  rolemenus  WHERE  roletype = "+roletype;
		List<RoleMenus> list=(List<RoleMenus>)commonDao.list(sql,new RoleMenusRowMapper());
		return list;
	}
}